package javaframework;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.Collections;
import java.util.List;

import framework.KInput;

public class JavaInput implements KInput, MouseListener, MouseMotionListener {
	private int my_x;
	private int my_y;
	private boolean my_touchDown;
	public JavaInput() {}

	@Override
	public synchronized boolean isTouchDown(int pointer) {
		return my_touchDown;
	}

	@Override
	public synchronized int getTouchX(int pointer) {
		return my_x;
	}

	@Override
	public synchronized int getTouchY(int pointer) {
		return my_y;
	}

	@Override
	public List<TouchEvent> getTouchEvents() {
		return Collections.emptyList();
	}

	@Override
	public synchronized void mouseDragged(MouseEvent e) {
		my_x = e.getX();
		my_y = e.getY();
	}

	@Override
	public synchronized void mouseMoved(MouseEvent e) {
		my_x = e.getX();
		my_y = e.getY();		
	}

	@Override
	public synchronized void mouseClicked(MouseEvent e) {
		my_x = e.getX();
		my_y = e.getY();		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
	}

	@Override
	public void mouseExited(MouseEvent e) {
	}

	@Override
	public synchronized void mousePressed(MouseEvent e) {
		my_x = e.getX();
		my_y = e.getY();
		my_touchDown = true;
	}

	@Override
	public synchronized void mouseReleased(MouseEvent e) {
		my_x = e.getX();
		my_y = e.getY();
		my_touchDown = false;
	}

}
